import request from '@/utils/request'

/**
 * 提交活动评价
 * @param {Object} data 评价数据
 * @returns {Promise}
 */
export function submitEvaluation(data) {
  return request({
    url: '/evaluation/submit',
    method: 'post',
    data
  })
}

/**
 * 获取用户评价
 * @param {number} activityId 活动ID
 * @returns {Promise}
 */
export function getUserEvaluation(activityId) {
  return request({
    url: '/evaluation/user',
    method: 'get',
    params: { activityId }
  })
}

/**
 * 获取活动评价列表
 * @param {Object} params 查询参数
 * @returns {Promise}
 */
export function getActivityEvaluations(params) {
  return request({
    url: '/evaluation/activity',
    method: 'get',
    params
  })
}

/**
 * 分页查询评价
 * @param {Object} params 查询参数
 * @returns {Promise}
 */
export function pageEvaluations(params) {
  return request({
    url: '/evaluation/page',
    method: 'get',
    params
  })
}

/**
 * 删除评价
 * @param {number} id 评价ID
 * @returns {Promise}
 */
export function deleteEvaluation(id) {
  return request({
    url: `/evaluation/${id}`,
    method: 'delete'
  })
}

/**
 * 获取评价统计信息
 * @param {number} activityId 活动ID
 * @returns {Promise}
 */
export function getEvaluationStats(activityId) {
  return request({
    url: '/evaluation/stats',
    method: 'get',
    params: { activityId }
  })
}

/**
 * 获取用户的所有评价
 * @param {Object} params 查询参数
 * @returns {Promise}
 */
export function getUserEvaluations(params) {
  return request({
    url: '/evaluation/list/user',
    method: 'get',
    params
  })
}

// 审核评价
export function auditEvaluation(evaluationId, status, remark) {
  return request({
    url: '/evaluation/audit',
    method: 'post',
    data: {
      evaluationId,
      status,
      remark
    }
  })
}

// 查询用户是否已评价
export function isUserEvaluated(activityId) {
  return request({
    url: `/evaluation/isEvaluated/${activityId}`,
    method: 'get'
  })
}